package cn.kooki.app.duobao.base;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.kooki.app.duobao.R;

/**
 * Created by xiong on 2015/12/13.
 */
public abstract class BaseNavActivity extends BaseActivity {


    public ImageButton topBack;

    public TextView topTextCenter;

    public ImageButton topCart;

    public TextView actionEdit;

    public RelativeLayout toolbar;

    public FrameLayout container;

    public ImageButton topRefresh;

    @Override
    protected void setToolbar() {
        topBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               onBackPressed();
            }
        });
        topBack.setVisibility(View.VISIBLE);
    }

    @Override
    protected void setLayoutContentView() {
        setContentView(R.layout.activity_base_nav);
        container = (FrameLayout) findViewById(R.id.nav_container);
        toolbar = (RelativeLayout) findViewById(R.id.toolbar);
        topCart = (ImageButton) findViewById(R.id.top_cart);
        topTextCenter = (TextView) findViewById(R.id.top_text_center);
        topBack = (ImageButton) findViewById(R.id.top_back);
        actionEdit = (TextView) findViewById(R.id.action_edit);
        topRefresh = (ImageButton) findViewById(R.id.top_refresh);
        setLayoutContainerView();
    }

    public abstract void setLayoutContainerView();


    public void setContainerView(int layoutid) {
        LayoutInflater.from(this).inflate(layoutid, container, true);
    }

    public void setTitle(String title) {
        topTextCenter.setText(title);
        topTextCenter.setVisibility(View.VISIBLE);
    }

    public void setTitle(int titleid) {
        topTextCenter.setText(titleid);
        topTextCenter.setVisibility(View.VISIBLE);
    }


}
